home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.applet.AudioClip;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dialog;
- import java.awt.Frame;
- import java.awt.Insets;
- import java.awt.LayoutManager;
- import java.awt.Menu;
- import java.awt.MenuBar;
- import java.awt.MenuComponent;
- import java.awt.MenuItem;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.event.WindowEvent;
- import java.awt.event.WindowListener;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLEncoder;
- import java.util.Enumeration;
- import java.util.Hashtable;
-
- public class MenuFrame2 extends Applet implements MouseListener, WindowListener {
- private String[] url;
- private String[] text;
- private String target;
- // $FF: renamed from: wi int
- private int field_0;
- // $FF: renamed from: he int
- private int field_1;
- public boolean hand = true;
- private AudioClip sound;
- public AudioClip clicSound;
- private boolean loopSound;
- public int pause = 200;
- // $FF: renamed from: X0 int
- int field_2;
- // $FF: renamed from: Y0 int
- int field_3;
- MenuBar pop;
- Dialog dialog;
- Color textColor;
- Color enterTextColor;
- Color backColor;
- Color enterBackColor;
- Color borderColor;
- int borderSize;
- Hashtable table;
- int maxWidth;
- int maxHeight;
- boolean isActive;
- int dialogWidth = 250;
- int dialogHeight = 200;
-
- public String getAppletInfo() {
- return "Name: MenuFrame2\r\nAuthor: Taiji Software";
- }
-
- public void register() {
- try {
- URL u = new URL("http://www.taijisoftware.com");
- ((Applet)this).getAppletContext().showDocument(u, "_blank");
- } catch (Exception e) {
- System.out.println(e);
- this.stop();
- }
- }
-
- public void init() {
- String codeBase = null;
-
- try {
- codeBase = (new URL(((Applet)this).getCodeBase().toString())).getHost();
- System.out.println("Copyright 1999, 2001 Taiji Software(tm)\nYour domain name is : " + codeBase);
- codeBase = codeBase.toUpperCase();
- } catch (Exception var16) {
- }
-
- if (!((Applet)this).getCodeBase().toString().toUpperCase().startsWith("FILE") || ((Applet)this).getParameter("debug") != null) {
- String regCode = ((Applet)this).getParameter("registration_code");
- if (regCode == null) {
- regCode = ((Applet)this).getParameter("reg_domain");
- if (regCode == null) {
- this.register();
- } else {
- if (regCode.length() == codeBase.length() + 4 && !codeBase.startsWith("WWW.")) {
- codeBase = "WWW." + codeBase;
- } else if (regCode.length() == codeBase.length() - 4 && codeBase.startsWith("WWW.")) {
- codeBase = codeBase.substring(4);
- }
-
- char[] chars = new char[codeBase.length()];
- codeBase.getChars(0, codeBase.length(), chars, 0);
- String key = new String("haricot");
- char[] chars2 = new char[key.length()];
- key.getChars(0, key.length(), chars2, 0);
-
- for(int i = 0; i < codeBase.length(); ++i) {
- int j;
- if (i >= key.length()) {
- j = i - key.length() * (i / key.length());
- } else {
- j = i;
- }
-
- chars[i] += chars2[j];
- chars[i] = (char)(chars[i] - chars[i] / 26 * 26 + 97);
- }
-
- String res = new String(chars);
- if (!res.equalsIgnoreCase(regCode)) {
- this.register();
- }
- }
- } else if (!regCode.equals("settevercsedegnamiaj") && !regCode.equals("8078")) {
- this.register();
- }
- }
-
- this.getParameters();
- ((Component)this).setBackground(this.getColor("background_color"));
-
- for(int n = 0; ((Applet)this).getParameter("text" + Integer.toString(n + 1)) != null; ++n) {
- }
-
- String s = ((Applet)this).getParameter("frame_title");
- if (s == null) {
- s = "Site map";
- }
-
- Frame f = new Frame();
- this.dialog = new Dialog(f, s);
- this.dialog.setLayout((LayoutManager)null);
- this.dialog.addWindowListener(this);
- s = ((Applet)this).getParameter("frame_X");
- int X;
- if (s != null) {
- X = Integer.parseInt(s);
- } else {
- X = 100;
- }
-
- s = ((Applet)this).getParameter("frame_Y");
- int Y;
- if (s != null) {
- Y = Integer.parseInt(s);
- } else {
- Y = 100;
- }
-
- this.dialog.setBounds(X, Y, 200, 200);
- if (((Applet)this).getParameter("frame_color") != null) {
- this.dialog.setBackground(this.getColor("frame_color"));
- }
-
- this.dialog.show();
- Insets insets = this.dialog.getInsets();
- this.field_2 = insets.left;
- this.field_3 = insets.top;
- this.dialog.setVisible(false);
- this.dialog.addMouseListener(this);
- if (((Applet)this).getParameter("item_text_color") != null) {
- this.textColor = this.getColor("item_text_color");
- } else {
- this.textColor = Color.yellow;
- }
-
- if (((Applet)this).getParameter("item_enter_text_color") != null) {
- this.enterTextColor = this.getColor("item_enter_text_color");
- } else {
- this.enterTextColor = Color.blue;
- }
-
- if (((Applet)this).getParameter("item_background_color") != null) {
- this.backColor = this.getColor("item_background_color");
- } else {
- this.backColor = Color.blue;
- }
-
- if (((Applet)this).getParameter("item_enter_background_color") != null) {
- this.enterBackColor = this.getColor("item_enter_background_color");
- } else {
- this.enterBackColor = Color.yellow;
- }
-
- if (((Applet)this).getParameter("item_border_color") != null) {
- this.borderColor = this.getColor("item_border_color");
- } else {
- this.borderColor = Color.black;
- }
-
- this.borderSize = 0;
- s = ((Applet)this).getParameter("item_border_size");
- if (s != null) {
- this.borderSize = Integer.parseInt(s);
- }
-
- this.pop = new MenuBar();
- this.giveMenu("");
- this.table = new Hashtable();
- int dec = 0;
- int h = 0;
-
- for(int i = 0; i < this.pop.getMenuCount(); ++i) {
- Menu menu = this.pop.getMenu(i);
- String label = ((MenuItem)menu).getLabel();
- String link = ((MenuItem)menu).getActionCommand();
- Item item = new Item(label, this, link, this.textColor, this.backColor, this.enterTextColor, this.enterBackColor, this.borderColor, this.borderSize, true);
- item.menuitem = menu;
- this.table.put(menu, item);
- item.topItem = true;
- this.dialog.add(item);
- ((Component)item).setBounds(this.field_2 + dec, this.field_3, ((Component)item).getPreferredSize().width, ((Component)item).getPreferredSize().height);
- h = ((Component)item).getPreferredSize().height;
- int maxwi = this.createItems(menu, dec, h);
- if (maxwi == 0) {
- maxwi = ((Component)item).getPreferredSize().width;
- }
-
- if (i == this.pop.getMenuCount() - 1) {
- this.maxWidth = maxwi + dec;
- }
-
- dec += ((Component)item).getPreferredSize().width;
- }
-
- Item item = new Item("", this, (String)null, this.textColor, this.backColor, this.textColor, this.backColor, this.borderColor, this.borderSize, true);
- item.topItem = true;
- this.dialog.add(item);
- ((Component)item).setBounds(this.field_2 + dec, this.field_3, this.dialogWidth - dec, ((Component)item).getPreferredSize().height);
- this.dialog.setSize(this.dialogWidth, this.dialogHeight);
- this.dialog.show();
- if (this.sound != null) {
- if (this.loopSound) {
- this.sound.loop();
- return;
- }
-
- this.sound.play();
- }
-
- }
-
- public int createItems(Menu menu, int x, int y) {
- int decy = 0;
- int maxw = 0;
-
- for(int i = 0; i < menu.getItemCount(); ++i) {
- MenuItem menuitem = menu.getItem(i);
- String label = menuitem.getLabel();
- Item item = new Item(label, this, "", this.textColor, this.backColor, this.enterTextColor, this.enterBackColor, this.borderColor, this.borderSize, false);
- this.dialog.add(item);
- int wi = ((Component)item).getPreferredSize().width;
- this.dialog.remove(item);
- if (wi > maxw) {
- maxw = wi;
- }
- }
-
- for(int i = 0; i < menu.getItemCount(); ++i) {
- MenuItem menuitem = menu.getItem(i);
- String label = menuitem.getLabel();
- String link = menuitem.getActionCommand();
- Item item = new Item(label, this, link, this.textColor, this.backColor, this.enterTextColor, this.enterBackColor, this.borderColor, this.borderSize, false);
- item.menuitem = menuitem;
- this.table.put(menuitem, item);
- this.dialog.add(item);
- ((Component)item).setBounds(this.field_2 + x, this.field_3 + y + decy, maxw, ((Component)item).getPreferredSize().height);
- if (menuitem instanceof Menu && ((Menu)menuitem).getItemCount() != 0) {
- this.createItems((Menu)menuitem, x + maxw, y + decy);
- item.hasChildren = true;
- }
-
- decy += ((Component)item).getPreferredSize().height;
- }
-
- if (decy > this.maxHeight) {
- this.maxHeight = decy;
- }
-
- return maxw;
- }
-
- public void showFirstChildren(MenuItem menuItem) {
- Enumeration e = this.table.keys();
-
- while(e.hasMoreElements()) {
- MenuItem menuitem = (MenuItem)e.nextElement();
- Item item = (Item)this.table.get(menuitem);
- if (((MenuComponent)menuitem).getParent().equals(menuItem)) {
- ((Component)item).setVisible(true);
- } else if (!item.topItem) {
- ((Component)item).setVisible(false);
- }
- }
-
- this.isActive = true;
- }
-
- public void showChildren(MenuItem menuItem) {
- Menu parent = (Menu)((MenuComponent)menuItem).getParent();
-
- for(int j = 0; j < parent.getItemCount(); ++j) {
- MenuItem menuitem = parent.getItem(j);
- if (!menuitem.equals(menuItem) && ((Item)this.table.get(menuitem)).hasChildren) {
- this.hideChildren(menuitem);
- }
- }
-
- if (((Item)this.table.get(menuItem)).hasChildren) {
- Menu menuEnter = (Menu)menuItem;
- if (menuEnter == null) {
- return;
- }
-
- for(int j = 0; j < menuEnter.getItemCount(); ++j) {
- MenuItem menuitem = menuEnter.getItem(j);
- ((Item)this.table.get(menuitem)).setVisible(true);
- }
- }
-
- }
-
- public void hideAllChildren() {
- Enumeration e = this.table.keys();
-
- while(e.hasMoreElements()) {
- Item item = (Item)this.table.get(e.nextElement());
- if (!item.topItem && ((Component)item).isVisible()) {
- ((Component)item).setVisible(false);
- }
- }
-
- this.isActive = false;
- }
-
- public void hideChildren(MenuItem menuItem) {
- Menu menuEnter = (Menu)menuItem;
- if (menuEnter != null) {
- for(int j = 0; j < menuEnter.getItemCount(); ++j) {
- MenuItem menuitem = menuEnter.getItem(j);
- if (menuitem instanceof Menu) {
- this.hideChildren(menuitem);
- }
-
- ((Item)this.table.get(menuitem)).setVisible(false);
- }
-
- }
- }
-
- public void stop() {
- if (this.sound != null) {
- this.sound.stop();
- }
-
- this.dialog.dispose();
- }
-
- public void getParameters() {
- this.field_0 = ((Component)this).getSize().width;
- this.field_1 = ((Component)this).getSize().height;
- String s = ((Applet)this).getParameter("pause");
- if (s != null) {
- this.pause = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("frame_width");
- if (s != null) {
- this.dialogWidth = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("frame_height");
- if (s != null) {
- this.dialogHeight = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("hand");
- if (s != null) {
- if (s.equals("0")) {
- this.hand = false;
- } else {
- this.hand = true;
- }
- }
-
- s = ((Applet)this).getParameter("sound_name");
- if (s != null) {
- this.sound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- s = ((Applet)this).getParameter("loop_sound");
- if (s != null) {
- if (s.equals("yes")) {
- this.loopSound = true;
- } else {
- this.loopSound = false;
- }
- }
-
- s = ((Applet)this).getParameter("clic_sound_name");
- if (s != null) {
- this.clicSound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- }
-
- public Menu giveMenu(String prof) {
- Menu menu = new Menu(((Applet)this).getParameter("text" + prof));
- int i = 0;
-
- while(true) {
- ++i;
- String prof2 = prof + "#" + Integer.toString(i);
- if (((Applet)this).getParameter("text" + prof2) == null) {
- return menu;
- }
-
- String s = ((Applet)this).getParameter("text" + prof2 + "#1");
- if (s == null) {
- s = ((Applet)this).getParameter("text" + prof2);
- if (s.equals("-")) {
- if (prof.equals("")) {
- this.pop.add(new Menu("---"));
- } else {
- menu.addSeparator();
- }
- } else {
- MenuItem menuitem = new MenuItem(((Applet)this).getParameter("text" + prof2));
- menuitem.setActionCommand(((Applet)this).getParameter("link" + prof2));
- if (prof.equals("")) {
- this.pop.add(new Menu(((Applet)this).getParameter("text" + prof2)));
- } else {
- menu.add(menuitem);
- }
- }
- } else if (prof.equals("")) {
- this.pop.add(this.giveMenu(prof2));
- } else {
- menu.add(this.giveMenu(prof2));
- }
- }
- }
-
- private Color getColor(String param) {
- String s = ((Applet)this).getParameter(param);
- if (s != null) {
- if (s.substring(0, 1).equals("#")) {
- s = s.substring(1);
- int i = Integer.parseInt(s, 16);
- return new Color(i);
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- public URL giveURL(String url) {
- try {
- if (url.toUpperCase().startsWith("HTTP")) {
- return new URL(url);
- } else if (url.toUpperCase().startsWith("FTP")) {
- int p = url.indexOf(":");
- int p2 = url.indexOf(":", p + 1);
- if (p2 != -1) {
- url = url.substring(0, p + 3) + URLEncoder.encode(url.substring(p + 3, url.length()));
- }
-
- p = url.indexOf("%40");
- if (p != -1) {
- url = url.substring(0, p) + "@" + url.substring(p + 3, url.length());
- }
-
- return new URL(url);
- } else {
- return new URL(((Applet)this).getCodeBase(), url);
- }
- } catch (MalformedURLException e) {
- System.out.println(e);
- return null;
- }
- }
-
- public void mouseClicked(MouseEvent e) {
- }
-
- public void mouseEntered(MouseEvent e) {
- }
-
- public void mouseExited(MouseEvent e) {
- }
-
- public void mousePressed(MouseEvent e) {
- this.hideAllChildren();
- }
-
- public void mouseReleased(MouseEvent e) {
- }
-
- public void windowActivated(WindowEvent e) {
- }
-
- public void windowClosed(WindowEvent e) {
- }
-
- public void windowClosing(WindowEvent e) {
- this.dialog.dispose();
- }
-
- public void windowDeactivated(WindowEvent e) {
- if (this.dialog != null) {
- this.hideAllChildren();
- }
-
- }
-
- public void windowDeiconified(WindowEvent e) {
- }
-
- public void windowIconified(WindowEvent e) {
- }
-
- public void windowOpened(WindowEvent e) {
- }
- }
-